# frozen_string_literal: true

module QA
  module EE
    module Page
      module Project
        module Secure
          class VulnerabilitySecurityTraining < QA::Page::Base
            view 'app/assets/javascripts/security_configuration/components/training_provider_list.vue' do
              element 'security-training-toggle'
            end

            def toggle_training_provider(name, toggle_to = "on")
              within_element('security-training-toggle', training_provider: name) do
                toggle = find('button.gl-toggle')
                checked = toggle[:class].include?('is-checked')
                toggle.click if (checked && toggle_to == "off") || (!checked && toggle_to == "on")
              end
            end
          end
        end
      end
    end
  end
end
